﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SolutionBLL;
using SolutionModel;
using SFast;
using SFast.Web;


public partial class admin_webconfig_NavbarDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void Add()
    {
        this.fun.Value = "addSave";
    }

    public void Edit()
    {
        T_NavbarBLL bll = new T_NavbarBLL();
        int id = 0;
        this.fun.Value = "EditSave";
        try
        {
            id = Convert.ToInt32(Request.QueryString["id"]);
        }
        catch (Exception e)
        {
            throw new Exception(MyJs.GetAlertStr("url参数“ID”值不是有效值。请传输数字的参数值。", "Navbar.aspx"), e);
        }

        bll.GetNavbarByID(id)._DataToForm("form1");
    }

    public void AddSave()
    {
        T_Navbar nav = Request._GetForm<T_Navbar>();
        nav.CreateTime = DateTime.Now;
        T_NavbarBLL bll = new T_NavbarBLL();
        bll.Add(nav);
        Response._WriteEnd("{\"info\":\"新导航添加成功！\",\"status\":\"y\"}");
    }

    public void EditSave()
    {
        T_Navbar nav = Request._GetForm<T_Navbar>();
        try
        {
            nav.ID = Convert.ToInt32(Request.QueryString["id"]);
        }
        catch (Exception ex)
        {
            throw new Exception("{\"info\":\"url参数“ID”值不是有效值。请传输数字的参数值。！\",\"status\":\"y\"}", ex);
        }
        T_NavbarBLL bll = new T_NavbarBLL();
        bll.Update(nav);
        Response._WriteEnd("{\"info\":\"导航编辑成功！\",\"status\":\"y\"}");
    }
}